//存放所有关于用户的接口
import request from "@/utils/request";
export default {
	//获取所有商品
	getallgoods() {
		return request.get("goodsRouter/getallgoods", {
			params: {},
		});
	},
	//获取id为什么得商品
	getGoodsId(goodsID) {
		return request.get("goodsRouter/getGoodsId", {
			params: {
				//getGoodsId?goodsID=2
				goodsID: goodsID,
			},
		});
	},
	//登录
	getlogin(username, password) {
		return request.get("user/login", {
			params: {
				username,
				password,
			},
		});
	},
	//获取购物车信息
	getcart(username) {
		return request.get("ordersRouter/getcart", {
			params: {
				username,
			},
		});
	},

	//功能:验证用户名是否存在
	checkName(username) {
		return request.get("/user/checkname", {
			params: {
				username,
			},
		});
	},

	//功能：注册
	reg(username, password) {
		return request.post("/user/reg", {
			username,
			password,
		});
	},
	//修改商品数量
	setGoodscart(goodsID, num, username) {
		return request.put("/ordersRouter/setGoodscart", {
			goodsID,
			num,
			username,
		});
	},
	//加入购物车
	addGoodsCart(goodsID, username) {
		return request.post("/ordersRouter/addGoodsCart", {
			goodsID,
			username,
		});
	},
	//排序
	getallgoodspai(style) {
		return request.get("goodsRouter/getallgoodspai", {
			params: { style },
		});
	},

	//删除购物车商品
	deleteGoodscart(goodsID, username) {
		return request({
			method: "delete",
			url: "/ordersRouter/deleteGoodscart",
			data: {
				goodsID,
				username,
			},
		});
	},
};
